//
//  HeadCell.m
//  WE
//
//  Created by iMacOne on 15/11/24.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "HeadCell.h"
#import "Size.h"
#import "ToolUtil.h"
@interface HeadCell ()
@property (nonatomic, strong)UIImageView * iconImageV;
@property (nonatomic, strong)UILabel * aLbl;
@property (nonatomic, strong)UIImageView * bigV;
@property (nonatomic, strong)UIImageView * smallV;
@property (nonatomic, strong)UIButton * adviBtn;



@end
@implementation HeadCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.bigV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, 100)];
        _bigV.backgroundColor = DEBUG_CLOLR;
        
        self.smallV = [[UIImageView alloc] initWithFrame:CGRectMake(WindowWidth - 70, 60, 50, 50)];
//        _smallV.frame = CGRectMake(WindowWidth - 70, 60, 50, 50);
        _smallV.backgroundColor = DEBUG_CLOLR;
        [_bigV addSubview:_smallV];
        self.iconImageV = [[UIImageView alloc] initWithFrame:CGRectMake(20,CGRectGetMaxY(_smallV.frame), 30, 30)];
        _iconImageV.backgroundColor = DEBUG_CLOLR;
        
        self.aLbl = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_iconImageV.frame) + 3,CGRectGetMaxY(_smallV.frame) + 2, [ToolUtil autoWidth:@"常见疾病及问题" width:0 height:20 num:12], 20)];
        _aLbl.font = FONT(12);
        _aLbl.text = @"常见疾病及问题";
        self.adviBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _adviBtn.frame = CGRectMake(_smallV.frame.origin.x, CGRectGetMaxY(_smallV.frame) + 2, 50, 20);
        _adviBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        _adviBtn.titleLabel.font = FONT(12);
//        btn.layer.masksToBounds = YES;
//        btn.layer.cornerRadius = 3;
//        btn.layer.borderWidth = 1;
//        btn.layer.borderColor = GRAYCOLOR.CGColor;
        _adviBtn.tag = 100;
        [_adviBtn setTitle:@"免费咨询" forState:UIControlStateNormal];
        [_adviBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        [_adviBtn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_bigV];
        [self.contentView addSubview:_adviBtn];
        [self.contentView addSubview:_aLbl];
        [self.contentView addSubview:_iconImageV];
        
    }
    return self;
}

+ (CGFloat)cellHeight
{
    NSString *str = @"色斑的形成不是单纯的色素沉积，是与不同人的体质、年龄、肌肤的老化程度、新陈代谢功能、日常防晒不到位、斑的层次等有关，祛斑应区分斑类型、斑层次，对症治疗，有效不反弹。" ;
    CGRect rect = [str boundingRectWithSize:CGSizeMake(WindowWidth - 20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:FONT(12)} context:nil];
    return  20 + rect.size.height;
    
}
- (void)clickBtn:(UIButton *)btn
{
    [self.delegate doClickBtn:btn.tag cell:self];
}

@end
